import React, { Component } from 'react'

export default class Test extends Component {
  constructor() {
    super()
    console.log('挂载阶段-constructor')
  }
  render() {
    console.log('挂载/更新阶段-render')
    return (
      <div id="test">
        Test,
        <button
          onClick={() => {
            // this.setState({
            //   xxx: 123,
            // })

            this.forceUpdate() //强制更新(不常用)
          }}
        >
          更新test组件
        </button>
      </div>
    )
  }
  componentDidMount() {
    console.log('挂载阶段-componentDidMount', document.getElementById('test'))
  }
  componentDidUpdate() {
    console.log('更新阶段-componentDidMount')
  }
  componentWillUnmount() {
    console.log('卸载阶段-componentWillUnmount')
  }
}
